import java.util.Scanner;

/** 
   A program reads two integer values
   and prints out the larger of the two.
   If the values are equal, only one of the value is printed.
*/
public class LexiOrder
{
   public static void main(String[] args)
   {
      // Print prompt to enter two words (strings)
      System.out.println("Please enter two words: ");

      // Read in both integer values
      Scanner in = new Scanner(System.in);
      String word1 = in.next();
      String word2 = in.next();
      int leng1=word1.length();
      int leng2=word2.length();
      int max;
      int leng=0;

      // Determine the correct alphabetical order of words
      // and print out the words in one line, in order.

      // Your work here
      if(leng1<leng2){
         max=leng2;
      }
      else{
         max=leng1;
      }
      for(int i=0;i<max;i++){
         if(word1.charAt(i)>word2.charAt(i)){
            System.out.print(word2);
            System.out.print(" ");
            System.out.print(word1);
            break;
         }
         else if(word1.charAt(i)<word2.charAt(i)){
            System.out.print(word1);
            System.out.print(" ");
            System.out.print(word2);
            break;
         }
         else{
            leng++;
            continue;
         }
      }
      if (leng==leng1){
         System.out.println(word1);
      }


   }
}